define(['app'], function(app) {
	'use strict';

	//实例化方法（群聊）
	var factory = function(Http, $interval) {

		var longConnect = null; //进行长连接对象
		var getMsgChat_callback = null; //聊天信息回调

		function init_socket() {
			//长连接执行
			if(longConnect != undefined) {
				longConnect = $interval(function() {
					//执行数据接收
					getChatMsg();
				}, 0.5); //间隔2秒定时执行
			}
		}

		//获取小图发送的消息
		function getChatMsg() {
			var Url = 'https://webllmapi.qyllm.com/message/getChatMsg?lastMsgId=0&loginCode=FJDKFIOEJ43JIF==';
			Http.getUrl(Url,
				function(data) {
					//在聊天窗体中新增一条消息
					if(getMsgChat_callback)
						getMsgChat_callback(IMUsers[msgID].chats);
				},
				function() {},
				function() {});
		}

		//返回信息
		return {
			//初始化
			init: function() {
				init_socket();
			},
			//签名
			chat_sign: function() {

			},
			//获取信息
			getChatMsg: function() {

			}
		};
	}

	factory.$inject = ['Http', '$interval'];
	
	return app.registerService("Chat", factory);
});